package de.tabuma.pm.externalproject.view;

import de.tabuma.lib.tabumaview;
import de.tabuma.pm.*;
import de.tabuma.pm.externalproject.entity.*;
import java.io.PrintWriter;
import java.util.*;
import javax.servlet.ServletContext;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

/**
 *
 * @author alefen
 */
public class view extends tabumaview {

    public view(String servlet, Hashtable parameter) {
        super(servlet, parameter);
    }

    @Override
    public void processRequest(ServletContext context, HttpServletRequest request, HttpServletResponse response, PrintWriter out) {
        
        String externProject = "external projects";
        if(request.getAttribute(constants.externalProjectErrorMessage)!=null) {
            out.println("<div class=\"errormessage\">");
            out.println("<div class=\"errormessage1\">");
            out.println(request.getAttribute(constants.externalProjectErrorMessage));
            out.println("</div>");
            out.println("</div>");
        }
        if(request.getAttribute(constants.externalProjectSuccessMessage)!=null) {
            out.println("<div class=\"infomessage\">");
            out.println("<div class=\"infomessage1\">");
            out.println(request.getAttribute(constants.externalProjectSuccessMessage));
            out.println("</div>");
            out.println("</div>");
        }

        
            boolean output = false;
            if(request.getAttribute(constants.addExternalProject)!=null) {
                output = true;
                create create = new create(this.getServlet(), this.getParameter());
                create.processRequest(context, request, response, out);
            }
            if(request.getAttribute(constants.updateExternalProject)!=null) {
                output = true;
                update update = new update(this.getServlet(), this.getParameter());
                update.processRequest(context, request, response, out);
            }
            if(request.getAttribute(constants.removeExternalProject)!=null) {
                output = true;
                remove remove = new remove(this.getServlet(), this.getParameter());
                remove.processRequest(context, request, response, out);
            }

            if(!output) {
                list lv = new list(this.getServlet(), this.getParameter());
                lv.processRequest(context, request, response, out);
            }
        
    }
}
